package main

import (
	"fmt"
)

func e() (res int, err error) {
	panic("出错了") //panic会被外面的recover接收到
	return
}

func main() {
	defer func() {
		err := recover() //拦截panic
		if err != nil {
			fmt.Println("拦截了异常：", err)
		}
	}()

	e()
}
